<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" isELIgnored="false" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>船舶管理</title>
    <link rel="stylesheet" type="text/css"
          href="../css/jquery/jquery-ui-1.8.23.custom.css" media="screen"/>
    <link rel="stylesheet" type="text/css"
          href="../css/validata/validationEngine.jquery.css" media="screen"/>

    <script type="text/javascript" src="../js/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript"
            src="../js/jquery/i18n/jquery.ui.datepicker-zh-CN.js"></script>
    <script type="text/javascript"
            src="../js/jquery/jquery-ui-1.8.23.custom.min.js"></script>
    <script type="text/javascript" src="../js/form/jquery.form.js"></script>
    <script type="text/javascript"
            src="../js/validata/jquery.validationEngine-zh_CN.js"></script>
    <script type="text/javascript"
            src="../js/validata/jquery.validationEngine.js"></script>
    <script type="text/javascript" src="../js/base/constants.js"></script>
</head>
<script type="text/javascript">
    $(document).ready(function () {
        //初始化表单验证引擎
        $("#shipForm").validationEngine("attach", {
            //消息位置
            promptPosition: "bottomRight",
            scroll: false
        });
        //初始化ajaxForm参数
        var options = {
            //提交方式
            type: "POST",
            //提交数据格式
            dataType: "json",
            //在提交之前做的操作
            beforeSubmit: function () {
                //进行表达验证,
                return $("#shipForm").validationEngine("validate");
            },
            //成功后做的操作
            success: function (responseText, statusText, xhr, $form) {
                parent.leftFrame.location.reload();
                alert(responseText.msg);
            }
        };
        //将表单提交设置成ajaxForm提交
        $('#shipForm').submit(function () {
            $(this).ajaxSubmit(options);
            return false;
        });
        //对字段,加载日历,datepicker_opt为日历参数，见base/constants.js
        $("#build_date").datepicker(datepicker_opt);
    });

    $(
            //美化按钮
            function () {
                //按钮类型
                $("input:button,input:reset", ".bts").button();
                $("#ship_name").autocomplete({
                    //数据源
                    source: function (request, response) {
                        $.post("demo-show", {
                            filters: "{'groupOp' : 'AND','rules' : [ {'field' : 'chn_name','op' : 'cn','data' : '" + $('#ship_name').val() + "'}]}",
                            size: 10,
                            pageNo: 1,
                            sidx: "ship_id",
                            sord: "asc"
                        }, function (data) {
                            response($.map(data.ships, function (item) {
                                return {
                                    label: item.chn_name,
                                    value: [item.chn_name, item.ship_id]
                                };
                            }));
                        }, "json");
                    },
                    //输入框有多少字符后，开始自动查询
                    minLength: 2,
                    select: function (event, ui) {
                        $("#ship_name").val(ui.item.label);
                        $("#ship_id").val(ui.item.value);
                        return;
                    },
                    open: function () {
                        $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
                    },
                    close: function (event, ui) {
                        $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
                    }

                });
            });
    //提交数据
    function doSave() {
        $("#shipForm").submit();
    }
</script>
<body>
<form id="shipForm" action="demo-save">
    <div class="ui-widget">
        <table class="ui-widget-content">
            <tr>
                <td>中文船名</td>
                <td><input class="validate[required]" type="text"
                           id="ship_name" name="ship.chn_name" value="${ship.chn_name}"/></td>
                <td>英文船名</td>
                <td><input type="text" name="ship.eng_name"
                           value="${ship.eng_name}"/></td>
                <td>曾用船名</td>
                <td><input type="text" name="ship.bak_name"
                           value="${ship.bak_name}"/></td>
            </tr>
            <tr>
                <td>船舶类型</td>
                <td><input type="text" name="ship.ship_type"
                           value="${ship.ship_type}"/></td>
                <td>航 区</td>
                <td><input type="text" name="ship.ship_zone"
                           value="${ship.ship_zone}"/></td>
                <td>海关编号</td>
                <td><input type="text" name="ship.ciq_no"
                           value="${ship.ciq_no}"/></td>
            </tr>
            <tr>
                <td>船 籍 港</td>
                <td><input type="text" name="ship.home_port"
                           value="${ship.home_port}"/></td>
                <td>联系电话</td>
                <td><input class="validate[custom[phone]]" type="text"
                           name="ship.phone_no" value="${ship.phone_no}"/></td>
                <td>移动电话</td>
                <td><input class="validate[custom[mobile]]" type="text"
                           name="ship.m_phone_no" value="${ship.m_phone_no}"/></td>
            </tr>
            <tr>
                <td>建造日期</td>
                <td><input class="validate[custom[date]]" type="text"
                           id="build_date" name="ship.build_date"
                           value='<s:date name="ship.build_date" format="yyyy-MM-dd" />'/></td>
                <td>建造单位</td>
                <td><input type="text" name="ship.build_factory"
                           value="${ship.build_factory}"/></td>
                <td>船体材料</td>
                <td><input type="text" name="ship.body_material"
                           value="${ship.body_material}"/></td>
            </tr>
            <tr>
                <td>总 价 值</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_worth" value="${ship.ship_worth}"/></td>
                <td>使用年限</td>
                <td><input class="validate[custom[integer]]" type="text"
                           name="ship.ship_use_year" value="${ship.ship_use_year}"/></td>
                <td>状 态</td>
                <td><input type="text" name="ship.status"
                           value="${ship.status}"/></td>
            </tr>
            <tr>
                <td>船东</td>
                <td><input type="text" name="ship.owner" value="${ship.owner}"/></td>
            </tr>
            <tr>
                <td colspan="8">
                    <hr>
                </td>
            </tr>
            <tr>
                <td>载货分值(标准分)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.load_point" value="${ship.load_point}"/></td>
            <tr>
                <td colspan="6"></td>
            </tr>
            <tr>
                <td>总 吨 位(吨)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.total_ton" value="${ship.total_ton}"/></td>
                <td>净 吨 位(吨)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.net_ton" value="${ship.net_ton}"/></td>
                <td>载重吨位(吨)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.load_ton" value="${ship.load_ton}"/></td>
            </tr>
            <tr>
                <td>设计船速(节)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_speed" value="${ship.ship_speed}"/></td>
                <td>船舶总长(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_long" value="${ship.ship_long}"/></td>
                <td>两柱间长(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.net_long" value="${ship.net_long}"/></td>
            </tr>
            <tr>
                <td>核定干舷(毫米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_board_long" value="${ship.ship_board_long}"/></td>
                <td>设计水线长(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.waterline_long" value="${ship.waterline_long}"/></td>
                <td>空载水线上高(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.net_waterline_height"
                           value="${ship.net_waterline_height}"/></td>
            </tr>
            <tr>
                <td>船舶型宽(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_wide" value="${ship.ship_wide}"/></td>
                <td>最 大 宽(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_max_wide" value="${ship.ship_max_wide}"/></td>
                <td>船舶型深(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.ship_deep" value="${ship.ship_deep}"/></td>
            </tr>
            <tr>
                <td>空载吃水首高(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.net_seagauge_head_height"
                           value="${ship.net_seagauge_head_height}"/></td>
                <td>空载吃水尾高(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.net_seagauge_tail_height"
                           value="${ship.net_seagauge_tail_height}"/></td>
                <td>备注</td>
                <td></td>
            </tr>
            <tr>
                <td>满载吃水首高(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.load_seagauge_head_height"
                           value="${ship.load_seagauge_head_height}"/></td>
                <td>满载吃水尾高(米)</td>
                <td><input class="validate[custom[number]]" type="text"
                           name="ship.load_seagauge_tail_height"
                           value="${ship.load_seagauge_tail_height}"/></td>
                <td valign="top" rowspan=3 colspan=2><textarea
                        name="ship.remarks" cols="30" rows="4">${ship.remarks } </textarea></td>
            </tr>
            <tr>
                <td>注册用户：</td>
                <td><input type="text" name="ship.reg_user_id"
                           value="${ship.reg_user_id.user_id}" disabled="disabled"/></td>
                <td>注册日期：</td>
                <td><input class="validate[custom[date]]" type="text"
                           name="ship.regDate"
                           value='<s:date name="ship.regDate" format="yyyy-MM-dd HH:mm:ss" />'
                           disabled="disabled"/></td>
            </tr>
            <tr>
                <td>修改用户：</td>
                <td><input type="text" name="ship.modi_user_id"
                           value="${ship.modi_user_id.user_id}" disabled="disabled"/></td>
                <td>修改日期：</td>
                <td><input class="validate[custom[date]]" type="text"
                           name="ship.modi_date"
                           value='<s:date name="ship.modi_date" format="yyyy-MM-dd HH:mm:ss" />'
                           disabled="disabled"/></td>
            </tr>
            <tr>
                <td colspan="6" align="center" class="bts"><input
                        type="button" name="btn" value="应用存盘" onclick="doSave();"/> <input
                        type="reset" name="btn" value="重置" onclick="doLinear();"/></td>
            </tr>
        </table>
    </div>
    <input type="hidden" id="ship_id" name="ship.ship_id" value="${ship.ship_id}"/>
</form>
</body>
</html>
